package com.sophialex.health.record.common.util;

import java.io.File;
import java.io.IOException;

import org.eclipse.core.runtime.Platform;

/**
 * 文件路径公共类
 * 
 * @author terry
 * 
 */
public class FileConfig {

	public final static String report = "report/ypgl";
	public final static String project_file = "project.xml";
	public final static String Zc = "zc";

	/**
	 * 获取报表文件路径
	 * 
	 * @return
	 */
	public static String getReportPath() {
		return getSysSpace() + report + "/";
	}

	/**
	 * 获取暂存目录
	 * 
	 * @return
	 */
	public static String getZcPath() {
		String str = getSysSpace() + "ypgl/zc";
		File f = new File(str);
		if (!f.exists()) {
			f.mkdirs();
		}
		return getSysSpace() + "ypgl/zc";
	}

	// 获取当前产品根目录
	public static String getSysSpace() {
		return Platform.getInstallLocation().getURL().getPath().substring(1);
	}

	// 在当前根目录下创建目录
	public static void createSysDir(String dirName) {
		File f = new File(getSysSpace() + "/" + dirName);
		if (!f.exists()) {
			f.mkdirs();
		}
	}

	// 创建临时文件
	public static File createTempFile(String fileName) {
		try {
			File file = File.createTempFile(fileName, ".temp");
			return file;
		} catch (IOException e) {
			e.printStackTrace();
		}
		return null;
	}
}
